package gr.atc.epart;

import java.util.List;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.LinearLayout.LayoutParams;

public class CategoriesAdapter extends BaseAdapter {

	private Context context;
	private List<String> categoryList;

	public CategoriesAdapter(Context context, List<String> categoriesList) {

		this.context = context;
		this.categoryList = categoriesList;

	}

	public int getCount() {

		return categoryList.size();

	}

	public Object getItem(int position) {
		return categoryList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		String categoryName = categoryList.get(position);
		return new CategoryView(this.context, categoryName);

	}

}

class CategoryView extends LinearLayout {

	String name;

	public CategoryView(Context context, String name) {

		super(context);

		this.name = name;

		this.setOrientation(HORIZONTAL);
		LinearLayout.LayoutParams moreParams = new LinearLayout.LayoutParams(
				LayoutParams.FILL_PARENT, 60);
		moreParams.setMargins(1, 1, 1, 1);
		moreParams.gravity = Gravity.CENTER_VERTICAL;
		

		TextView more = new TextView(context);
		more.setText(name);
		more.setTextSize(30f);
		more.setTextColor(Color.BLACK);
		addView(more, moreParams);

	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
